package du.com.listview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HomeworkActivity extends AppCompatActivity {
    private ListView mHomework;
    private SimpleAdapter mHomeworkAdapter;
    private List<Map<String,Object>> data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_homework);
        mHomework= (ListView) findViewById(R.id.lv_homework);
        SubjectAdapt s=new SubjectAdapt(this,R.layout.homework_item);
        String[] from=new String[]{"homeworkImage","homeworkName","completeNum","homeworkDeadline","techerComment"};
        int[] to=new int[]{R.id.im_homework,R.id.tx_homeworkName,R.id.tx_completeNum,R.id.tx_homeworkDeadline,R.id.tx_techerComment};
        mHomeworkAdapter=new SimpleAdapter(this,initData(),R.layout.homework_item,from,to);
        mHomework.setAdapter(mHomeworkAdapter);

    }

    private List<Map<String,Object>> initData() {
        data =new ArrayList<Map<String, Object>>();
        for(int i=0;i<=9;i++){
            Map<String,Object> map=new HashMap<String,Object>();
            map.put("homeworkImage",R.drawable.homework2x);
            map.put("homeworkName","9月25日英语作业4");
            map.put("completeNum","完成题量0/10");
            map.put("homeworkDeadline","已批改");
            map.put("techerComment","hhhhhhh");
            data.add(map);
        }
        return data;
    }
}
